<?php
include("../common.inc.php");
include("function_common.php");
require_once(INC_PATH.'/dbbak.class.php');
InitGP(array('action','dbdir')); //初始化变量全局返回
$db->link;

$backupDir = 'data';
$DbBak = new DbBak($db->link,$backupDir);
if($action=="backup"){
$DbBak->backupDb('zzqsscms');
showmsg("备份数据库成功!","dbbak.php");
}elseif ($action=="restore" and !empty($dbdir))
{
$DbBak->restoreDb('zzqsscms',null,$dbdir);

showmsg("恢复数据库成功!","dbbak.php");
}

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/common.css" type="text/css" />
<title>管理区域</title>
</head>

<body>
<div id="man_zone">
  <table width="99%" border="0" align="center"  cellpadding="3" cellspacing="1" class="table_style">
    <tr>
      <td colspan="2" align="center" class="left_title_1"><a href="?action=backup">【点击备份当前数据库】</a></td>
    </tr>
    <tr>
      <td width="36%" align="center" class="left_title_1">数据库备份</td>
      <td width="64%" align="center">操作</td>
    </tr>
	
	<?php
	$dh = opendir($backupDir.'/*');
   while ($file = readdir($dh)){
	if($file!='.'&& $file!='..'){
	
	?>
    <tr>
      <td class="left_title_2"><?php echo $file?>&nbsp;&nbsp;&nbsp;</td>
      <td><a  href="javascript:if(confirm('恢复以后无法还原，确定要恢复数据库吗?'))location='action=restore&dbdir=<?php echo $file?>'">【恢复备份】</a> </td>
    </tr>
	
	<?php
		}
   }
   closedir($dh);
	
	?>
  </table>
</div>
</body>
</html>
